package com.gkzf.ai.module.system.dal.mysql.appUser;

import com.gkzf.ai.framework.common.pojo.PageResult;
import com.gkzf.ai.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.gkzf.ai.framework.mybatis.core.mapper.BaseMapperX;
import com.gkzf.ai.module.system.controller.app.appUser.vo.UsersPageReqVO;
import com.gkzf.ai.module.system.dal.dataobject.appUser.UsersDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 用户 Mapper
 *
 * @author 国科智飞
 */
@Mapper
public interface UsersMapper extends BaseMapperX<UsersDO> {

    default PageResult<UsersDO> selectPage(UsersPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UsersDO>()
                .likeIfPresent(UsersDO::getUsername, reqVO.getUsername())
                .likeIfPresent(UsersDO::getNickname, reqVO.getNickname())
                .eqIfPresent(UsersDO::getAvatarUrl, reqVO.getAvatarUrl())
                .eqIfPresent(UsersDO::getGender, reqVO.getGender())
                .eqIfPresent(UsersDO::getMobile, reqVO.getMobile())
                .eqIfPresent(UsersDO::getPassword, reqVO.getPassword())
                .eqIfPresent(UsersDO::getUnionId, reqVO.getUnionId())
                .eqIfPresent(UsersDO::getMpOpenId, reqVO.getMpOpenId())
                .eqIfPresent(UsersDO::getAppOpenId, reqVO.getAppOpenId())
                .eqIfPresent(UsersDO::getStatus, reqVO.getStatus())
                .eqIfPresent(UsersDO::getRegisterSource, reqVO.getRegisterSource())
                .betweenIfPresent(UsersDO::getLastLoginTime, reqVO.getLastLoginTime())
                .eqIfPresent(UsersDO::getLastLoginIp, reqVO.getLastLoginIp())
                .betweenIfPresent(UsersDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UsersDO::getId));
    }

}